<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="Handheldfriendly" content="true">
    <!-- 微软的老式浏览器 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <!-- 显示窗口 宽度 是 客户端的 屏幕 宽度 （就是 满屏 ！），显示的文字和图形的初始比例 是 1.0 -->
    <link rel="stylesheet" href="css/layui.mobile.css">
    <link rel="stylesheet" type="text/css" href="css/att.css">
    <script src="js/common.js"></script>
	<title>身份证</title>
</head>
<body style="background-color: #fff;">
	<div class="hitop">   
		<div class="tubiao"><img src="images/img/3211.png" alt=""></div>
                <div class="lione"><a style="color:#000;">身份证</a></div>
        <div class="bigk">
            <div class="kuang">
                <div id="list"></div>
                <!--<div class="addbox" id="upload-btn" onclick="qkimg()"></div>-->
                <p>为了保障靠谱交友，保证人员信息真实性，需要您提交身份证件照正/反面~</p>
            </div>
        </div>
        <p class="ts"></p>
        <!--<div class="quetwo"><a  class="oktwo" onclick="rz(this)">立即认证</a></div>-->
	</div>
    <input style="display: none" type="file" id="file" accept="image/png,image/gif,image/jpeg,image/jpg">
  <script src="js/jquery/jquery-2.2.4.min.js"></script>
    <script src="js/common.js"></script>
  <script src="js/jquery/upload.js"></script>
  <script src="js/jquery/layer.js"></script>
  <script src="js/utils.js"></script>
  <script>
      Utils.historyBack(function () {
          window.location.href = '/certification.html';
      });
      rzzt();
      var img=[];
      function qkimg() {
          if(img.length==2){
              img=[];
              $("#list").html("")
          }
      }
      new Upload({
          button :"#upload-btn",
          file : '#file',
          module : 'album',
          success : function (url) {
              //$(".kuang").html("");
              img.push(url);
              var strs=`<img src=${url}>`;
              $(strs).appendTo("#list");
              if(img.length==2){
                  $(".addbox").hide();
              }
          },
          error : function (data) {
              alert('网络错误');
          }
      });
      
      function rz(obj) {
          var $this=$(obj);
          var id=$this.attr("data-id");
          if(id==2){
              return false;
          }
          if(img.length!=2){
              layer.open({
                  content:"身份证必须上传正反面两张哦~",time:2,skin:"msg"
              });
              return false;
          }
          $.ajax({
              type : "POST",
              url : getRequestUrl("/user/upload_auth_data"),
              data:{
                  auth_type:2,
                  data:img.toString()
              },
              success : function(datas) {
                  console.log(datas);
                  if(datas.response_params.result==0){
                      layer.open({
                          content: '身份证上传成功,等待系统审核',
                          time: 2,
                          skin:'msg'
                      });
                  }
              },
              error : function(err) {
            	  dealCPErrorResponse(err);
              }
          });
      }

      function rzzt() {
          $.ajax({
              type : "GET",
              url : getRequestUrl("/user/get_auth_info"),
              success : function(datas) {
                  console.log(datas);
                  var arr=datas.response_params.result;
                  $.each(arr,function (i,el) {
                      var sts="";
                     if(el.auth_type=="2"){
                         console.log(el.data);
                         img=el.data.pics;
                         if(el.data.pics.length!=0){
                            $.each(el.data.pics,function (j,item) {
                                sts+=`<img src=${item}>`
                            })
                         }
                         //$(".ts").html(el.reason)
                     }
                     if (el.status==2){
                         $(".oktwo").attr("data-id","2")
                     }

                     $(sts).appendTo("#list")
                  });
                  $("#loading").hide();
              },
              error : function(err) {
                  dealCPErrorResponse(err);
              }
          });
      }
  </script>
</body>
</html>